Skip to content

Set ethernet and wifi MAC address #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 3, 2016

Conversation

ghost
Copy link

@ghost ghost commented Dec 1, 2016

This connects #19.
This connects #15

@ghost ghost added the s: review label Dec 1, 2016
@ghost
Copy link
Author

ghost commented Dec 1, 2016

The openwrt image must be changed:

  • set_mac init script must be removed
  • uccp420wlan init script must be removed
  • Add 93-uccp420wlan file in /etc/modules.d with the following content:
mac80211
uccp420wlan

|| check_otp_version(VERSION_REG1_OFFSET))
return;

node = fdt_path_offset(blob, "/uccp@18480000");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add an alias for Wi-Fi node as we do for ethernet, as change in dts node name will require a change in the code ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return;
}

/* Set Wifi STA and AP MAC address in device tree */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check whether the addresses are valid before writing ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return -1;
}

if (version != 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the 1 as macro ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this arch will work from a backwards compatibility point of view. Imagine we had to release a version 2 OTP layout that was a superset of version 1. The code change should be as simple as here is the extra stuff to read if you see version 2. i.e. it should hit the version 1 code already here (not duplicate it) and then carry on to any further versions.

We would never change layouts already released meaning you can always assume a new version is a superset. So based on this how about we drop this file and just wrap the read_otp calls in conditions of greater than version N (in this case 1)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


#ifdef CONFIG_WINBOND_OTP
if (!is_valid_ethaddr(mac_addr)
&& !check_otp_version(VERSION_REG0_OFFSET)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this logical AND to the end of above line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would conflict with the coding style guidelines of u-boot.

else
printf("Could not read MAC address from OTP\n");
}
#endif
#ifdef CONFIG_OF_CONTROL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling this config means, we wont be setting the mac address from OTP, is this what we want ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling CONFIG_OF_CONTROL means that we will retrieve the MAC address from the DTB if we did not find a valid MAC in the OTP.


#define VERSION_REG0_OFFSET 0x1002
#define VERSION_REG1_OFFSET 0x2002

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing as you've added this perhaps we could move all otp layout defines into here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


return 0;
}
int ft_board_setup(void *blob, bd_t *bd)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the need for the weak ref, no one is going to override us right? Just define ft_board_setup and call fixup_wifi directly from it as we have no cpu setup to do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed weak ref

@Avinash95 Avinash95 self-assigned this Dec 2, 2016
@ghost ghost force-pushed the task-15 branch 6 times, most recently from 77f2eb1 to 2a6812e Compare December 2, 2016 11:59

DECLARE_GLOBAL_DATA_PTR;

static void fixup_wifi(void *blob)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just keep this function to fix wifi mac addresses, and write different one to overwrite calibration data ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#ifndef WINBOND_OTP_H
#define WINBOND_OTP_H

#define MAC_ADDR_LEN 6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to do with this chip. It too can go to otp.h as it's related to layout?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

|| check_otp_version(VERSION_REG1_OFFSET))
return;

node = fdt_path_offset(blob, "wifi0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be "wlan0" to keep in line with the interface names

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment on CreatorDev/openwrt#117

@abhijit-mahajani-imgtec
Copy link
Contributor

abhijit-mahajani-imgtec commented Dec 2, 2016

Verified that eth and wifi STA mac addresses are assigned properly.
However WiFi AP mac address looks incorrect.

root@OpenWrt:/# hexdump -n 6 -v -e '/1 "%02X"' /proc/device-tree/uccp@18480000/m
ac-address0
0019F5890D3Broot@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# hexdump -n 6 -v -e '/1 "%02X"' /proc/device-tree/uccp@18480000/m
ac-address1
68E8FC0F68E8root@OpenWrt:/#

Signed-off-by: Avinash Tahakik <[email protected]>
Signed-off-by: Francois Berder <[email protected]>
ethernet MAC address is stored in the OTP, read it
and write it into dtb, so kernel can use updated MAC address

Signed-off-by: Avinash Tahakik <[email protected]>
Signed-off-by: Francois Berder <[email protected]>
The MAC address for Wifi STA and AP are read from the OTP,
then written in the wifi driver node of the device-tree.
Concerning calibration data, only DCXO is read from the OTP
and overwrites the first byte of the calibration parameter
in the device tree.

Signed-off-by: Francois Berder <[email protected]>
The version of register 0 and 1 must be greater or equal to 1,
otherwise do not attempt to read any data from the OTP.

Signed-off-by: Francois Berder <[email protected]>
@Ham22 Ham22 merged commit 455f049 into CreatorDev:2015.10 Dec 3, 2016
@Ham22 Ham22 removed the s: review label Dec 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants